package com.example.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.example.pojo.documentNumberPojo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface documentNumberMapp {

    // 插入一行数据到表中
    @DS("newMscLowCodeTest")  // 可以根据实际数据库切换不同的数据源
    @Insert("insert into ddm_document_number(" +
            "id, create_time, update_time, creator, process_status, sys_update_user, sys_audit_user, sys_audit_time, sys_deleted, " +
            "documentCategory, topic, documentNumber) " +
            "VALUES (" +
            "#{id}, #{create_time}, #{update_time}, #{creator}, #{process_status}, #{sys_update_user}, #{sys_audit_user}, #{sys_audit_time}, #{sys_deleted}, " +
            "#{documentCategory}, #{topic}, #{documentNumber})")
    void insertOne(documentNumberPojo documentNumberPojo);

    // 查询所有数据
    @DS("newMscLowCodeTest")
    @Select("Select * from ddm_document_number where sys_deleted = 0")
    List<documentNumberPojo> queryAll();

    // 根据ID查询单个数据
    @DS("newMscLowCodeTest")
    @Select("Select * from ddm_document_number where id = #{id} and sys_deleted = 0")
    documentNumberPojo queryById(String id);

    // 根据ID更新数据
    @DS("newMscLowCodeTest")
    @Update("UPDATE ddm_document_number SET " +
            "create_time = #{create_time}, " +
            "update_time = #{update_time}, " +
            "creator = #{creator}, " +
            "process_status = #{process_status}, " +
            "sys_update_user = #{sys_update_user}, " +
            "sys_audit_user = #{sys_audit_user}, " +
            "sys_audit_time = #{sys_audit_time}, " +
            "sys_deleted = #{sys_deleted}, " +
            "documentCategory = #{documentCategory}, " +
            "topic = #{topic}, " +
            "documentNumber = #{documentNumber} " +
            "WHERE id = #{id} and sys_deleted = 0")
    void updateDocumentNumber(documentNumberPojo documentNumberPojo);
}
